/*
 * @Description:
 * @Author: 稽辉
 * @Date: 2025-03-12 17:13:20
 * @LastEditTime: 2025-03-14 16:58:50
 * @LastEditors: 稽辉
 */
import { http } from '@/utils/http'

// Response interface
export interface CommentsRes {
  /*数据对象 */
  /* */
  id: number

  /* */
  user_content: string

  /* */
  user_avatar: string

  /* */
  user_name: string

  /* */
  user_id: number

  /* */
  parent_id: number

  /* */
  reply_id: number

  /* */
  reply_name: string

  /* */
  like_count: number

  /* */
  is_like: boolean

  /* */
  created_time: Date
}

export const getGoodCommentsByIdAPI = (goodId: string) => {
  return http<CommentsRes>({
    method: 'GET',
    url: '/comments/get-goods-comments',
    data: {
      goodId,
    },
  })
}

export const getTableTotalAPI = (goodId: string) => {
  return http<number>({
    method: 'GET',
    url: '/comments/get-good-comment-total',
    data: {
      goodId,
    },
  })
}
export const postGoodCommentAPI = (goodId: string, userId: number) => {
  return http<number>({
    method: 'POST',
    url: '/comments/add-good-comment',
    data: {
      goodId,
      userId,
    },
  })
}
//删除评论（一级评论删除后，对应的二级评论也删除）
export const deleteGoodCommentAPI = (commentId: number) => {
  return http<number>({
    method: 'DELETE',
    url: `/comments/delete-good-comment?commentId=${commentId}`,
  })
}
//增加评论
export const addGoodCommentAPI = (data: any, goodId: string) => {
  return http<number>({
    method: 'POST',
    url: `/comments/add-good-comment?goodId=${goodId}`,
    data,
  })
}
//点赞评论
export const likeCommentAPI = (data: object[]) => {
  return http<number>({
    method: 'POST',
    url: `/comments/like-comment`,
    data,
  })
}
